package com.errorfinding.rabbitmq.eight;

import com.errorfinding.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * 消费者02
 * 死信模式
 */
public class Consumer02 {
    //死信队列名称
    private static final String dead_queue = "dead_queue";


    public static void main(String[] args) throws IOException, TimeoutException {
        //获取信道
        Channel channel = RabbitMqUtils.getChannel();

        System.out.println("02等待接收消息");
        DeliverCallback deliverCallback = (tag,message)->{
            System.out.println("02接收到的消息："+message.getBody());
        };
        channel.basicConsume(dead_queue,true,deliverCallback,tag->{});

    }
}
